package com.tledu.hdfs;

import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class PracticeQuestions3 {
    public static void main(String[] args) throws IOException {
        String filePath1 = args[0];
        String filePath2 = args[1];
        String result1 = HdfsUtils.readHdfsFile(filePath1, "utf8");
        String result2 = HdfsUtils.readHdfsFile(filePath2, "utf8");
        String[] wordArr1 = result1.split("\n");
        String[] wordArr2 = result2.split("\n");
        Set<String> set1 = new HashSet<>(Arrays.asList(wordArr1));
        Set<String> set2 = new HashSet<>(Arrays.asList(wordArr2));
        // 求交集
        set1.retainAll(set2);
        // 遍历set1
        set1.forEach(System.out::println);
    }
}
